import pymysql

conn = pymysql.connect(host="127.0.0.1",
                       port=3306,
                       user="root",
                       password="root",
                       database="books")
'''获取游标'''
cursor = conn.cursor()
"""保存sql语句"""
sql = "select version();"
"""执行sql"""
cursor.execute(sql)
print(cursor.fetchall())
cursor.close()
conn.close()
